package com.mpp.admin.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.mpp.admin.entity.PageEntity;
import com.mpp.admin.entity.Permission;
import com.mpp.admin.service.PermissionService;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @author mapp
 * @des 资源
 * @date 2019/2/15
 */
@Controller
@RequestMapping("/permission")
public class PermissinController {

    @Autowired
    private PermissionService permissionService;

    @RequestMapping("/index")
    public String index() {
        return "permission";
    }

    @RequestMapping("/getAll")
    @ResponseBody
    public PageEntity getAll(Integer page, Integer limit, Permission permission) {



        return (PageEntity) permissionService.page(PageEntity.build(page, limit),
                new QueryWrapper().eq(StringUtils.isNotBlank(permission.getName()), "name", permission.getName()));
    }
}
